import config from '@/config/config.js';
import http from '@/api/http.js'

let workmanshipCompositionRequest={
    list(workmanshipId,page=1,limit=10,callBack){
        // 获取token
        let token = localStorage.getItem("token");
        if(token){
            let url = config.productionBaseUrl + "/composition/list?page="+page + "&limit=" + limit;
            if(workmanshipId){
                    url += "&workmanshipId=" + workmanshipId;
            }
            console.log(url);
            http.get(url,callBack);
        }else{
            callBack(undefined);
        }
    },add(workmanshipComposition,callBack){
        let token = localStorage.getItem("token");
        if(token){
            let url = config.productionBaseUrl + "/composition/add";
            console.log(url);
            http.post(url,workmanshipComposition,callBack);
        }else{
            callBack(undefined);
        }
    },edit(workmanshipComposition,callBack){
        let token = localStorage.getItem("token");
        if(token){
            let url = config.productionBaseUrl + "/composition/edit";
            console.log(url);
            http.post(url,workmanshipComposition,callBack);
        }else{
            callBack(undefined);
        }
    },query(workmanshipId,processNumber,callBack){
        // 获取token
        let token = localStorage.getItem("token");
        if(token){
            let url = config.productionBaseUrl + "/composition/query?workmanshipId="+ workmanshipId + "&processNumber=" + processNumber;

            console.log(url);
            http.get(url,callBack);
        }else{
            callBack(undefined);
        }
    }
}

export default workmanshipCompositionRequest;